<template>
	<view class="userInfo-container">
		<view class="topBox">
			<image :src="userInfo.avatarUrl" class="avatar"></image>
			<view class="nickName">{{userInfo.nickName}}</view>
		</view>

		<view class="panel-list">
			<!-- 第一个面板 -->
			<view class="panel">
				<view class="panel-body">
					<view class="panel-item">
						<text>8</text>
						<text>收藏的店铺</text>
					</view>

					<view class="panel-item">
						<text>14</text>
						<text>收藏的商品</text>
					</view>

					<view class="panel-item">
						<text>18</text>
						<text>关注的商品</text>
					</view>

					<view class="panel-item">
						<text>84</text>
						<text>足迹</text>
					</view>
				</view>
			</view>
			
			<!-- 第二个面板 -->
			<view class="panel">
				<view class="panel-title">我的订单</view>
				<view class="panel-body">
					<view class="panel-item">
						<image src="/static/images/profile/icon1.png" class="icon"></image>
						<text>待收款</text>
					</view>
					<view class="panel-item">
						<image src="/static/images/profile/icon2.png" class="icon"></image>
						<text>待收货</text>
					</view>
					<view class="panel-item">
						<image src="/static/images/profile/icon3.png" class="icon"></image>
						<text>退款/退货</text>
					</view>
					<view class="panel-item">
						<image src="/static/images/profile/icon4.png" class="icon"></image>
						<text>全部订单</text>
					</view>
				</view>
			</view>
			
			<!-- 第三个面板 -->
			<view class="panel">
				<view class="panel-item-btn">
					<text>收货地址</text>
					<uni-icons type="arrowright"></uni-icons>
				</view>
				<view class="panel-item-btn">
					<text>联系客服</text>
					<uni-icons type="arrowright"></uni-icons>
				</view>
				<view class="panel-item-btn" @click="logout">
					<text>退出登录</text>
					<uni-icons type="arrowright"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		name: "my-userInfo",
		data() {
			return {

			};
		},
		computed: {
			...mapState('m_address', ['userInfo'])
		},
		methods:{
			...mapMutations('m_address', ['updateAddress', 'updateUserInfo', 'updateToken']),
			async logout(){
				const [err, res] = await uni.showModal({
					title:'提示',
					content:'是否退出登录'
				}).catch(err=>err)
				
				if(res && res.confirm){
					this.updateAddress({})
					this.updateUserInfo({})
					this.updateToken('')
				}
			}
		}
	}
</script>

<style lang="scss">
	.userInfo-container {
		background-color: #f4f4f4;
		height: 100%;

		.topBox {
			background-color: #007aff;
			height: 40%;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.avatar {
				width: 200rpx;
				height: 200rpx;
				border-radius: 100rpx;
				border: 4rpx solid #FFFFFF;
				box-shadow: 2rpx 2rpx 10rpx black;
			}

			.nickName {
				font-size: 36rpx;
				font-weight: bold;
				color: white;
				margin-top: 20rpx;
			}
		}
	}

	.panel-list {
		// background-color: rgba(12,12,12,0.5);
		height: 60%;
		position: relative;
		top: -30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.panel {
			background-color: #FFFFFF;
			width: 90%;
			// height: 100rpx;
			border-radius: 10rpx;
			// box-shadow: 2rpx 2rpx 10rpx gray;
			margin-bottom: 15rpx;
			
			.panel-title{
				// background-color: #303133;
				height: 75rpx;
				line-height: 75rpx;
				text-indent: 20rpx;
				font-size: 26rpx;
				border-bottom: 1rpx solid #efefef;
			}

			.panel-body {
				display: flex;
				flex-direction: row;
				justify-content: space-around;
				padding: 20rpx;
				
				.panel-item {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.icon {
						width: 80rpx;
						height: 80rpx;
					}

					text {
						font-size: 26rpx;
						margin-bottom: 5rpx;
					}
				}
			}
		}
	}
	
	.panel-item-btn{
		display: flex;
		height: 60rpx;
		justify-content: space-between;
		padding: 20rpx;
		font-size: 28rpx;
		line-height: 60rpx;
	}
</style>
